{% extends "base.html" %}

{% block headers %}
<link rel="stylesheet" href="{{ url_for('static', filename='css/plans.css') }}">
{% endblock %}

{% block content %}
    <div class="row">
        <div class="col-md-4 col-sm-6">
            <h3>Account Management</h3>
            <div class="btn-grid">
                {% if not current_user.subscribed %}<a href="{{ url_for('subscribe') }}" class="btn btn-primary" role="button"><i class="far fa-envelope"></i> Join Mailing List</a>{% endif %}
                <a href="{{ url_for('user.edit_user_profile') }}" class="btn btn-primary" role="button"><i class="fas fa-edit"></i> Edit Account</a>
                <a href="{{ url_for('user.change_password') }}" class="btn btn-primary" role="button"><i class="fas fa-lock"></i> Change Password</a>
                {% if current_user.stripe.customer_id %}<a href="{{ url_for('customer_portal') }}" class="btn btn-primary" role="button"><i class="fas fa-credit-card"></i> Billing and Invoices</a>{% endif %}
                <a href="{{ url_for('delete_account') }}" class="btn btn-danger" role="button"><i class="far fa-trash-alt"></i> Delete Account</a>
            </div>
        </div>
        <div class="col-md-8 col-sm-6">
            <h3>Tokens</h3>
            <p>
                <b>Current Plan</b>: {{ current_user.plan.name }} at <b>${{ current_user.plan.price }}</b> / {% if '-year' in current_user.plan.key %}year{% else %}month{% endif %} & <b>{{ current_user.plan.limit // 1000 }}k</b> calls / day
                {% if current_user.has_subscription %}
                    <br/>
                    <b>Token Limit Overage</b>:
                    {% if current_user.allow_overage %}
                    <i class="fas fa-check"></i> Enabled <a href="{{ url_for('disable_overage') }}" class="btn btn-danger" role="button"><i class="fas fa-times"></i> Disable</a>
                    {% else %}
                    <i class="fas fa-times"></i> Disabled <a href="{{ url_for('enable_overage') }}" class="btn btn-primary" role="button"><i class="fas fa-check"></i> Enable</a>
                    {% endif %}
                    at <b>$0.08</b> per 1000 calls monthly
                {% endif %}
            </p>
            {% if current_user.tokens %}
            <table id="token-table">
                <tr>
                    <th class="center">
                        <a href="{{ url_for('token_usage') }}" title="Token usage chart"><i class="fas fa-chart-area"></i></a>
                        <a href="{{ url_for('new_token') }}" title="Create new token"><i class="fas fa-plus"></i></a>
                    </th>
                    <th>Name</th>
                    <th>Enabled</th>
                    <th>Value</th>
                </tr>
                {% for token in current_user.tokens %}
                {% include 'include/token_row.html' %}
                {% endfor %}
            </table>
            {% else %}
            <p><a href="{{ url_for('new_token') }}" class="btn btn-primary" role="button"><i class="fas fa-plus"></i> Create New Token</a></p>
            {% endif %}
        </div>
    </div>
    <br/>
    <!-- <div class="row">
        {% if invoices %}
        <div class="col-md-4 col-sm-6">
            <h3>Recent Invoices</h3>
            {% include 'include/invoices.html' %}
        </div>
        {% endif %}
    </div>
    <br/> -->
    {% include 'include/plans.html' %}
{% endblock %}